//
//  STMatchViewController.swift
//  RouterPushProtocol
//
//  Created by Toj on 2/22/22.
//

import UIKit

class STMatchViewController: STBaseViewController {
   
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.addSubview(testView)
        testView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.width.equalTo(100)
            make.height.equalTo(44)
        }
        
        view.addSubview(barcodeButton)
        barcodeButton.frame = CGRect(x: 0, y: 100, width: 100, height: 100)
        
        view.addSubview(tableButton)
        tableButton.frame = CGRect(x: 150, y: 100, width: 100, height: 100)
    }
    
    @objc func didTapBarcode() { navigationController?.pushViewController(BarCodeViewController(), animated: true)
    }
    
    @objc func didTapBarcode2() {
        
        print("-->toj: self: \(self.cm_objectAddress)")
        print("-->toj: parent: vc isPresent: \(st_isPresent)")
        
        if let nav = navigationController {
            print("-->toj: parent: nav isPresent: \(nav.st_isPresent)")
        } else {
            print("-->toj: parent: nav isPresent: nil")
        }
        
        if let tab = UIApplication.shared.delegate?.window??.rootViewController as? UITabBarController {
            print("-->toj: parent: tab isPresent: \(tab.st_isPresent)")
        }
        else {
            print("-->toj: parent: tab isPresent: nil")
        }
    }
    
    @objc func didTapTable() {
        navigationController?.pushViewController(STTableViewController(), animated: true)
    }
    
    private lazy var barcodeButton: UIButton = {
        let view = UIButton()
        view.setTitle("Barcode", for: .normal)
        view.backgroundColor = .red
        view.addTarget(self, action: #selector(didTapBarcode), for: .touchUpInside)
        return view
    }()
    
    private lazy var tableButton: UIButton = {
        let view = UIButton()
        view.setTitle("Table", for: .normal)
        view.backgroundColor = .red
        view.addTarget(self, action: #selector(didTapTable), for: .touchUpInside)
        return view
    }()
    
    /** <#NOTE#> **/
    private lazy var testView: TSView = {
        let view = TSView(edgeInsets: .zero)
        view.backgroundColor = .random
        return view
    }()
}
